Changeset 5964 for pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
- Timestamp:
- Apr 8, 2019 1:24:10 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r5928 r5964 480 480 */ 481 481 Endpoint::Endpoint() 482 : writer(NULL), threadDescMutex(NULL), m ainThreadOnly(false),483 mainThread (NULL), pendingJobSize(0)482 : writer(NULL), threadDescMutex(NULL), mediaListMutex(NULL), 483 mainThreadOnly(false), mainThread(NULL), pendingJobSize(0) 484 484 { 485 485 if (instance_) { … … 1713 1713 PJSUA2_CHECK_EXPR( pj_mutex_create_simple(pjsua_var.pool, "threadDesc", 1714 1714 &threadDescMutex) ); 1715 1716 PJSUA2_CHECK_EXPR( pj_mutex_create_recursive(pjsua_var.pool, "mediaList", 1717 &mediaListMutex) ); 1715 1718 } 1716 1719 … … 1780 1783 } 1781 1784 1785 if (mediaListMutex) { 1786 pj_mutex_destroy(mediaListMutex); 1787 mediaListMutex = NULL; 1788 } 1789 1782 1790 status = pjsua_destroy2(flags); 1783 1791 … … 2039 2047 void Endpoint::mediaAdd(AudioMedia &media) 2040 2048 { 2041 if (mediaExists(media)) 2042 return; 2049 pj_mutex_lock(mediaListMutex); 2050 2051 if (mediaExists(media)) { 2052 pj_mutex_unlock(mediaListMutex); 2053 return; 2054 } 2043 2055 2044 2056 mediaList.push_back(&media); 2057 pj_mutex_unlock(mediaListMutex); 2045 2058 } 2046 2059 2047 2060 void Endpoint::mediaRemove(AudioMedia &media) 2048 2061 { 2062 pj_mutex_lock(mediaListMutex); 2049 2063 AudioMediaVector::iterator it = std::find(mediaList.begin(), 2050 2064 mediaList.end(), … … 2054 2068 mediaList.erase(it); 2055 2069 2070 pj_mutex_unlock(mediaListMutex); 2056 2071 } 2057 2072 2058 2073 bool Endpoint::mediaExists(const AudioMedia &media) const 2059 2074 { 2075 bool exists; 2076 2077 pj_mutex_lock(mediaListMutex); 2060 2078 AudioMediaVector::const_iterator it = std::find(mediaList.begin(), 2061 2079 mediaList.end(), 2062 2080 &media); 2063 2064 return (it != mediaList.end()); 2081 exists = (it != mediaList.end()); 2082 pj_mutex_unlock(mediaListMutex); 2083 return exists; 2065 2084 } 2066 2085
Note: See TracChangeset
for help on using the changeset viewer.