~ubuntu-branches/ubuntu/quantal/virtualbox/quantal

« back to all changes in this revision

Viewing changes to src/VBox/Devices/Audio/coreaudio.c

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-04-05 12:41:55 UTC
  • mfrom: (3.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120405124155-i7b39tv5ddwhubbe
Tags: 4.1.12-dfsg-2
* Upstream has replaced the 4.1.12 tarball with a new one that fixes a
  crash when creating host only interfaces. (Closes: #667460)
  - Add 36-tarball-respin.patch which contains the diff between the old
    and the new tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
370
370
 
371
371
static char* caCFStringToCString(const CFStringRef pCFString)
372
372
{
373
 
    const char *pszTmp = NULL;
374
373
    char *pszResult = NULL;
375
374
    CFIndex cLen;
 
375
#if 0
 
376
    /**
 
377
     * CFStringGetCStringPtr doesn't reliably return requested string instead return depends on "many factors" (not clear which)
 
378
     * ( please follow the link
 
379
     *  http://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html
 
380
     * for more details). Branch below allocates memory using mechanisms which hasn't got single method for memory free:
 
381
     * RTStrDup - RTStrFree
 
382
     * RTMemAllocZTag - RTMemFree
 
383
     * which aren't compatible, opposite to CFStringGetCStringPtr CFStringGetCString has well defined
 
384
     * behaviour and confident return value.
 
385
     */
 
386
    const char *pszTmp = NULL;
376
387
 
377
388
    /* First try to get the pointer directly. */
378
389
    pszTmp = CFStringGetCStringPtr(pCFString, kCFStringEncodingUTF8);
390
401
            pszResult = NULL;
391
402
        }
392
403
    }
 
404
#else
 
405
    /* If the pointer isn't available directly, we have to make a copy. */
 
406
    cLen = CFStringGetLength(pCFString) + 1;
 
407
    pszResult = RTMemAllocZTag(cLen * sizeof(char), RTSTR_TAG);
 
408
    if (!CFStringGetCString(pCFString, pszResult, cLen, kCFStringEncodingUTF8))
 
409
    {
 
410
        RTStrFree(pszResult);
 
411
        pszResult = NULL;
 
412
    }
 
413
#endif
393
414
 
394
415
    return pszResult;
395
416
}
691
712
            CFRelease(name);
692
713
            if (pszName && pszUID)
693
714
                LogRel(("CoreAudio: Using output device: %s (UID: %s)\n", pszName, pszUID));
694
 
            RTStrFree(pszUID);
 
715
            RTMemFree(pszUID);
695
716
        }
696
 
        RTStrFree(pszName);
 
717
        RTMemFree(pszName);
697
718
    }
698
719
    else
699
720
        LogRel(("CoreAudio: [Output] Unable to get output device name (%RI32)\n", err));
1463
1484
    UInt32 uSize = 0; /* temporary size of properties */
1464
1485
    UInt32 uFlag = 0; /* for setting flags */
1465
1486
    CFStringRef name; /* for the temporary device name fetching */
1466
 
    char *pszName;
1467
 
    char *pszUID;
 
1487
    char *pszName = NULL;
 
1488
    char *pszUID = NULL;
1468
1489
    ComponentDescription cd; /* description for an audio component */
1469
1490
    Component cp; /* an audio component */
1470
1491
    AURenderCallbackStruct cb; /* holds the callback structure */
1515
1536
            CFRelease(name);
1516
1537
            if (pszName && pszUID)
1517
1538
                LogRel(("CoreAudio: Using input device: %s (UID: %s)\n", pszName, pszUID));
1518
 
            RTStrFree(pszUID);
 
1539
            if (pszUID)
 
1540
                RTMemFree(pszUID);
1519
1541
        }
1520
 
        RTStrFree(pszName);
 
1542
        if (pszName)
 
1543
            RTMemFree(pszName);
1521
1544
    }
1522
1545
    else
1523
1546
        LogRel(("CoreAudio: [Input] Unable to get input device name (%RI32)\n", err));