Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1813)

Unified Diff: webrtc/modules/utility/source/helpers_ios.mm

Issue 1206783002: Cleanup of iOS AudioDevice implementation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More cleanup Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/utility/source/helpers_ios.mm
diff --git a/webrtc/test/testsupport/iosfileutils.mm b/webrtc/modules/utility/source/helpers_ios.mm
similarity index 51%
copy from webrtc/test/testsupport/iosfileutils.mm
copy to webrtc/modules/utility/source/helpers_ios.mm
index f3615ed6814b41a696fd04da166a96a59237c2a9..ea95823a2fdb850d868b4f38cbe377c194f59e3d 100644
--- a/webrtc/test/testsupport/iosfileutils.mm
+++ b/webrtc/modules/utility/source/helpers_ios.mm
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 The WebRTC Project Authors. All rights reserved.
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -10,18 +10,15 @@
#if defined(WEBRTC_IOS)
-#if !defined(__has_feature) || !__has_feature(objc_arc)
-#error "This file requires ARC support."
-#endif
-
+#import <AVFoundation/AVFoundation.h>
#import <Foundation/Foundation.h>
-#include <string.h>
+#include <pthread.h>
#include "webrtc/base/checks.h"
-#include "webrtc/typedefs.h"
+#include "webrtc/modules/utility/interface/helpers_ios.h"
namespace webrtc {
-namespace test {
+namespace ios {
// TODO(henrika): move to shared location.
// See https://code.google.com/p/webrtc/issues/detail?id=4773 for details.
@@ -39,22 +36,39 @@ std::string StdStringFromNSString(NSString* nsString) {
[charData length]);
}
-// For iOS, resource files are added to the application bundle in the root
-// and not in separate folders as is the case for other platforms. This method
-// therefore removes any prepended folders and uses only the actual file name.
-std::string IOSResourcePath(std::string name, std::string extension) {
- @autoreleasepool {
- NSString* path = NSStringFromStdString(name);
- NSString* fileName = path.lastPathComponent;
- NSString* fileType = NSStringFromStdString(extension);
- // Get full pathname for the resource identified by the name and extension.
- NSString* pathString = [[NSBundle mainBundle] pathForResource:fileName
- ofType:fileType];
- return StdStringFromNSString(pathString);
+bool CheckAndLogError(BOOL success, NSError* error) {
+ if (!success) {
+ NSLog(@"Error: %ld, %@", (long)error.code, error.localizedDescription);
tkchin_webrtc 2015/07/06 03:46:29 I think it is better to stick with webrtc LOG macr
henrika_webrtc 2015/07/07 16:01:39 Done.
henrika_webrtc 2015/07/08 15:20:10 Not sure if my way is what you wanted. Hope it loo
tkchin_webrtc 2015/07/08 19:41:14 Yeah, just wanted LS_ERROR. Format is up to you, l
+ return false;
}
+ return true;
+}
+
+std::string GetCurrentThreadDescription() {
+ NSString* name = [NSString stringWithFormat:@"%@", [NSThread currentThread]];
tkchin_webrtc 2015/07/06 03:46:29 I would add these functions to logging.cc so that
henrika_webrtc 2015/07/07 16:01:39 Great idea, let me add support for GetThreadId as
henrika_webrtc 2015/07/08 15:20:10 Found a way. Done. Given new calls in the added un
+ return StdStringFromNSString(name);
+}
+
+std::string GetThreadId() {
+ char buf[21]; // Big enough to hold a kuint64max plus terminating NULL.
+ pid_t thread_id = pthread_mach_thread_np(pthread_self());
+ CHECK_LT(snprintf(buf, sizeof(buf), "%i", thread_id),
+ static_cast<int>(sizeof(buf)))
+ << "Thread id is bigger than uint64??";
+ return std::string(buf);
+}
+
+std::string GetThreadInfo() {
+ return "@[tid=" + GetThreadId() + "]";
+}
+
+AVAudioSession* GetAudioSession() {
tkchin_webrtc 2015/07/06 03:46:29 Is this necessary since it's a one-liner?
henrika_webrtc 2015/07/07 16:01:39 Removed.
+ // Implicit initialization happens when we obtain a reference to the
+ // AVAudioSession object.
+ return [AVAudioSession sharedInstance];
}
-} // namespace test
+} // namespace ios
} // namespace webrtc
#endif // defined(WEBRTC_IOS)

Powered by Google App Engine
This is Rietveld 408576698